package m3d28;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class bMapSet {
    public static void main(String[] args) {
        //遍历map第一种方法
        Map<String,String> map1 = new HashMap<>();
        String v1 = map1.put("a","1");
        String v3 = map1.put("b","2");
        String v4 = map1.put("c","3");
        String v5 = map1.put("d","4");

        //把所有键取出来放到set集合
        Set<String> set = map1.keySet();

        Iterator<String> stringIterator = set.iterator();
        while(stringIterator.hasNext()){
            String str = stringIterator.next();
            String value = map1.get(str);
            //通过key找值
            System.out.println("key = "+value);
        }

        //增强for循环
    }
}
